package com.pac.location.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.common.tools.StringTools;
import com.pac.location.bean.LocationBean;
import com.pac.location.dao.LocationDao;
import com.pac.location.service.LocationService;

/**
 * 区域信息service实现
 * 
 * @author lujun.chen
 * @version [版本号, 2015年3月1日]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
@Service(value = "locationService")
public class LocationServiceImpl implements LocationService {

	@Autowired
	private LocationDao locationDao;

	@Override
	public List<LocationBean> queryLocation(LocationBean locationBean) {
		return locationDao.queryLocation(locationBean);
	}

	@Override
	public LocationBean findLocation(LocationBean locationBean) {
		if (null == locationBean) {
			return null;
		}

		List<LocationBean> locationList = locationDao
				.queryLocation(locationBean);
		if (null != locationList && locationList.size() > 0) {
			return locationList.get(0);
		}
		return null;
	}

	@Override
	public List<LocationBean> queryLocationByParentId(String parentId) {

		if (StringTools.isNull(parentId)) {
			return null;
		}

		LocationBean locationBean = new LocationBean();
		locationBean.setParentId(parentId);

		return locationDao.queryLocation(locationBean);
	}

}
